package com.dragon.www.haier.model.xml;

import android.support.annotation.NonNull;


import com.dragon.www.haier.adapter.ICommonArrayAdapter;
import com.dragon.www.haier.model.DevicePacket;
import com.dragon.www.haier.net.AppSocket;
import com.dragon.www.haier.net.AppUDPPacket;

import java.util.HashMap;
import java.util.List;



/**
 * 用于操作指令的存储
 * Created by Administrator on 2015/11/19 19:00.
 * Author: songxy
 * Email: thinkdata@163.com
 */
public abstract class ATemplate {

    public static final String PACKET_HEADER = "HEAD";
    /**
     * 设备指令模板code
     */
    protected HashMap<DictionaryGroupItem, List<DictionaryItem>> codeTemplate = new
            HashMap<>();

    /**
     * 设备请求指令模板requestpacket
     */
    protected HashMap<String, List<DictionaryItem>> requestTemplate = new HashMap<>();

    public abstract AppUDPPacket encodePacket(ICommonArrayAdapter obj, String packetType, String... actionArgs);

    public abstract DevicePacket decodePacket(AppUDPPacket packet, AppSocket appSocket) throws CodeParseException;

    public void setCodeTemplate(@NonNull DictionaryGroupItem groupItem,
                                List<DictionaryItem> items) {
        this.codeTemplate.put(groupItem, items);
    }

    public void setPacketTemplate(@NonNull String groupName,
                                  List<DictionaryItem> items) {
        this.requestTemplate.put(groupName, items);
    }

}
